package com.haisen.dataobject.dto;

import lombok.Data;
import org.springframework.util.StringUtils;

import java.util.ArrayList;
import java.util.List;


@Data
public class VerifyPubSubDTO {

    private Long id;
    private String subscribe;
    private String subscribeName;
    private String publishIds;
    private List<Long> publishIdList;
    private String publishNames;
    private String ctype;

    public void setPublishIds(String publishIds) {
        String[] ids = publishIds.split(",");
         for (String id : ids){
             if (StringUtils.isEmpty(id)) {
                 continue;
             }
             getPublishIdList().add(Long.valueOf(id));
         }
        this.publishIds = publishIds;
    }

    public List<Long> getPublishIdList() {
         if (publishIdList == null){
             publishIdList = new ArrayList<>();
         }
        return publishIdList;
    }

    public VerifyPubSubDTO() {
    }

    public VerifyPubSubDTO(Long id,String subscribe, String subscribeName,String publishIds, String publishNames, String ctype) {
        this.id = id;
        this.subscribe = subscribe;
        this.subscribeName = subscribeName;
        this.publishIds = publishIds;
        this.publishNames = publishNames;
        this.ctype = ctype;
    }
}
